package sna;

import java.util.Set;
import java.util.concurrent.CopyOnWriteArraySet;

import org.apache.commons.collections15.Factory;

import edu.uci.ics.jung.algorithms.generators.random.BarabasiAlbertGenerator;
import edu.uci.ics.jung.graph.Graph;
import edu.uci.ics.jung.graph.UndirectedSparseGraph;

public class test {
	
	public static void main(String[] argv){
		
		Factory<MyNode> MyNodeFactory = new Factory<MyNode>(){
			public MyNode create(){
				return new MyNode();
			}
		};
		Factory<MyLink> MyLinkFactory = new Factory<MyLink>(){
			public MyLink create(){
				return new MyLink();
			}
		};
		Factory<Graph<MyNode, MyLink>> GraphFactory = new Factory<Graph<MyNode, MyLink>>(){
			public Graph<MyNode, MyLink> create(){
				return new UndirectedSparseGraph<MyNode, MyLink>();
			}
		};
		
		Set<MyNode> SeedV = new CopyOnWriteArraySet<MyNode>();
		
		for (int i = 0;i<2;i++){
			MyNode V1 = MyNodeFactory.create();
			SeedV.add(V1);
		}
		
		int num = 8;
		
		BarabasiAlbertGenerator BA = new BarabasiAlbertGenerator(GraphFactory, MyNodeFactory, MyLinkFactory, 2, 2, SeedV);

		
		
		BA.evolveGraph(num);	
		
		Graph<MyNode,MyLink> g = BA.create();
		
		AverageShortestPathCalculator<MyNode, MyLink> asp = new AverageShortestPathCalculator(g);
		AverageClusteringCoefficientCalculator<MyNode, MyLink> acc = new AverageClusteringCoefficientCalculator(g);
		
		System.out.println(g);
		System.out.println(asp.getAverageDistance());
		System.out.println(acc.getCC());
	}

}
class MyNode{
	static int VCount = 0;
	int id;
	public MyNode(){
		this.id = VCount++;
	}
	public String toString(){
		return "" + id;
	}
}
		
class MyLink{
	static int ECount =0;
	int id;
	public MyLink(){
		this.id = ECount++;
	}
	public String toString(){
		return "" + id;
	}
}